﻿<s:SurfaceWindow x:Class="MTBrainStorm.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:s="http://schemas.microsoft.com/surface/2008"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:Views="clr-namespace:MTBrainStorm.Views"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
                 xmlns:ViewModels="clr-namespace:MTBrainStorm.ViewModels" 
                 xmlns:Commands="clr-namespace:MTBrainStorm.Framework.Commands;assembly=MTBrainStorm.Framework" 
                 Title="MainWindow" Height="400" Width="1000"
                 WindowState="Maximized" WindowStyle="None">    
    
    <s:SurfaceWindow.DataContext>
        <ViewModels:MainWindowViewModel />
    </s:SurfaceWindow.DataContext>

    <s:SurfaceWindow.Resources>        
        <DataTemplate DataType="{x:Type ViewModels:MultiTouchElementViewModel}">
                <Viewbox>
                    <Views:Element />
                </Viewbox>
        </DataTemplate>

        <DataTemplate DataType="{x:Type ViewModels:TouchInkCanvasViewModel}">
            <Viewbox>
                <Views:TouchInkCanvas />
            </Viewbox>
        </DataTemplate>

        <DataTemplate DataType="{x:Type ViewModels:JointViewModel}">
                <Views:Joint />
        </DataTemplate>
        
        <DataTemplate DataType="{x:Type ViewModels:VirtualKeyboardViewModel}">
            <Viewbox>
                <Views:VirtualKeyboard />
            </Viewbox>
        </DataTemplate>
        
        <DataTemplate DataType="{x:Type ViewModels:TextElementViewModel}">
            <Viewbox>
                <Views:TextElement />
            </Viewbox>
        </DataTemplate>
        
        <DataTemplate DataType="{x:Type ViewModels:DocumentNodeViewModel}">
            <Viewbox>
                <Views:DocumentNodeElement />
            </Viewbox>
        </DataTemplate>
        
        <DataTemplate DataType="{x:Type ViewModels:DocumentRootViewModel}">
            <Viewbox>
                <Views:DocumentRootElement />
            </Viewbox>
        </DataTemplate>

        <ImageBrush x:Key="WindowBackground" Stretch="UniformToFill" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>
    </s:SurfaceWindow.Resources>

    <Grid Background="{StaticResource WindowBackground}">
        <Image x:Name="trash" Width="100" Height="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="/MTBrainStorm;component/Resources/Empty%20Trash_128x128.png" RenderTransformOrigin="0.5,0.5">
            <Image.RenderTransform>
                <RotateTransform Angle="45" />
            </Image.RenderTransform>
        </Image>

        <Image x:Name="trash2" Width="100" Height="100" HorizontalAlignment="Right" VerticalAlignment="Top" Source="/MTBrainStorm;component/Resources/Empty%20Trash_128x128.png" RenderTransformOrigin="0.5,0.5">
            <Image.RenderTransform>
                <RotateTransform Angle="-135" />
            </Image.RenderTransform>
        </Image>

        <ItemsControl ItemsSource="{Binding Joints}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
        <s:ScatterView ItemsSource="{Binding Elements}" s:ScatterViewItem.ContainerManipulationCompleted="ContainerManipulationCompleted">
            <i:Interaction.Triggers>
                <Commands:AttachedEventTrigger EventName="s:ScatterViewItem.ContainerManipulationCompleted">
                    <Commands:InvokeCommand Command="{Binding JoinOrUnjoinIfPossible}" PassEventArgsToCommand="True" />
                </Commands:AttachedEventTrigger>
            </i:Interaction.Triggers>
            <s:ScatterView.ItemContainerStyle>
                <Style TargetType="s:ScatterViewItem">
                    <Setter Property="Center" Value="{Binding Position, Mode=TwoWay}" />
                    <Setter Property="Orientation" Value="{Binding Rotation, Mode=TwoWay}" />
                    <Setter Property="Width" Value="{Binding ActualWidth}" />
                    <Setter Property="Height" Value="{Binding ActualHeight}" />
                    <Setter Property="IsTopmostOnActivation" Value="True" />
                    <Setter Property="SingleInputRotationMode" Value="ProportionalToDistanceFromCenter" />
                </Style>
            </s:ScatterView.ItemContainerStyle>
        </s:ScatterView>
        <Views:Toolbox HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
            <Views:Toolbox.RenderTransform>
                <RotateTransform Angle="180"/>
            </Views:Toolbox.RenderTransform>
        </Views:Toolbox>
        <Views:Toolbox HorizontalAlignment="Right" VerticalAlignment="Bottom" />
    </Grid>
</s:SurfaceWindow>
